<template>
    <div class="field-item">
        <ItemString
            v-if="item.type === 'string'"
            :item="item"
            :dataKey="dataKey"
            @update="onUpdate"
        />
        <ItemArray
            v-if="item.type === 'array'"
            :item="item"
            :proto="item.repeat"
            :dataKey="dataKey"
            @update="onUpdate"
        />
    </div>
</template>

<script>
import ItemString from "./itemString";
import ItemArray from "./itemArray";
export default {
    name: "FieldItem",
    components: {
        ItemString,
        ItemArray
    },
    props: {
        item: {
            type: Object,
            default() {
                return {};
            }
        },
        dataKey: {
            type: String
        }
    },
    methods: {
        onUpdate({ newValue }) {
            // this.$bus.$emit("update_config_data", {
            //     key,
            //     newValue
            // });
            this.$emit("update", {
                key: this.dataKey,
                newValue
            });
        }
    }
};
</script>

<style scoped lang="less">
.field-item {
    font-size: 16px;
}
</style>
